﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using TradingAppDal;

namespace TradingApp.Helper
{
    public class UIHelper
    {
        public static void ChangeToCurrentDirectory()
        {
            String path = System.Reflection.Assembly.GetExecutingAssembly().Location;
            path = System.IO.Path.GetDirectoryName(path);
            Directory.SetCurrentDirectory(path);
        }
        public static void HandleApplicationException(System.Exception ex)
        {
        }
        public static void OpenFormAsMdiChild(Form form, Form mdiParent)
        {
            OpenFormAsMdiChild(form, mdiParent, FormWindowState.Maximized);
        }

        public static void OpenFormAsMdiChild(Form form, Form mdiParent, FormWindowState windowState)
        {
            form.MdiParent = mdiParent;
            form.WindowState = windowState;
            form.Dock = DockStyle.Fill;
            form.BringToFront();
            form.Show();
            
            //form.WindowState = FormWindowState.Minimized;
            //form.WindowState = FormWindowState.Maximized;
        }
        public static void BindReports(ComboBox cboReport)
        {
            //cboReport.Items.Clear();
            ReportingDal oReportingDal = new ReportingDal();
            List<string> lstViews = oReportingDal.GetReportingViews(TradingAppSettings.REPORT_SCHEMA_STR);
            cboReport.DataSource = lstViews;
            if (!String.IsNullOrEmpty(TradingAppSettings.DefaultReport))
            {
                cboReport.Text = TradingAppSettings.DefaultReport;
            }
            else
            {
                cboReport.SelectedIndex = 0;
            }
        }
    }
}
